﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace bsy
{
    public partial class sy_upgrede : Form
    {
        //连接字符串
        private string connStr = Properties.Settings.Default.bsyConnectionString;
        private string cart_id;

        public string Cart_id
        {
            get { return cart_id; }
            set { cart_id = value; }
        }
        private string cart_name;

        public string Cart_name
        {
            get { return cart_name; }
            set { cart_name = value; }
        }
        private string cart_price;

        public string Cart_price
        {
            get { return cart_price; }
            set { cart_price = value; }
        }

        public sy_upgrede()
        {
            InitializeComponent();
        }

        private void sy_upgrede_Load(object sender, EventArgs e)
        {
           //显示要升级的列表卡
            show_sy_upgrade();
        }

        public void show_sy_upgrade()
        {
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            string sql = string.Format("select cart_id ID,name 卡名,price 价格 from cart where cart.type='{0}'", "huiyuanka");

            SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            this.sy_upgrade.DataSource = ds.Tables[0].DefaultView;
            this.sy_upgrade.Columns[0].Visible = false;
            ds.Dispose();
            conn.Close();
        }

        //双击点击
        private void sy_upgrade_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {

            }
            else
            {
                cart_id = this.sy_upgrade.Rows[e.RowIndex].Cells[0].Value.ToString();
                cart_name = this.sy_upgrade.Rows[e.RowIndex].Cells[1].Value.ToString();
                cart_price = this.sy_upgrade.Rows[e.RowIndex].Cells[2].Value.ToString();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }

    }
}
